<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #canvas {
            border: 1px solid black;
        }
    </style>
</head>
<body>
<canvas width="600px" height="400px" id="canvas"></canvas>
<script>
    const cvs = document.querySelector("#canvas")

    cvs.width = 800
    cvs.height = 600

    const ctx = cvs.getContext("2d")

    ctx.font = '40px 宋体'

    // 设置空心文字
    ctx.strokeText(' this is a book', 100, 100, 300)

    // 文本对齐方式  start end left right center
    ctx.textAlign = 'center'
    // 设置实体文字
    ctx.fillText(' this is a book', 200, 400, 300)
</script>
</body>
</html>